{include file='public/header' /}
<!-- 正文开始 -->
<style type="text/css">
    /* .layui-table-cell {
         height: 80px;
         line-height: 80px;
     }*/
    th .layui-table-cell {
        height: 30px;
        line-height: 30px;
    }
    th .laytable-cell-1-0-7 {
        height: 30px;
        line-height: 30px;
    }
    .layui-table img {
        width: 100px;
        height: 60px;
    }
</style>
<!-- 正文开始 -->
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <div class="layui-form toolbar">

                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">订&nbsp;&nbsp;单&nbsp;&nbsp;号：</label>
                        <div class="layui-input-inline">
                            <input name="goods_no" value="" class="layui-input" type="text" placeholder="输入订单号"/>
                        </div>
                    </div>

                    <div class="layui-inline" style="padding-left: 20px;">
                        <button class="layui-btn icon-btn " lay-filter="formSubSearchTbAdv" lay-submit>
                            <i class="layui-icon">&#xe615;</i>搜索
                        </button>

                    </div>
                </div>
            </div>

            <table id="tableUser" lay-filter="tableUser"></table>

            <!--表格tab-->
            <div class="layui-tab layui-tab-brief" lay-filter="tableXTab">

                <div class="layui-tab-content" style="padding-left: 0;padding-right: 0;">

                    <div class="layui-tab-item layui-show">

                        <table id="xTable1" lay-filter="xTable1"></table>
                    </div>
                    <!-- <div class="layui-tab-item ">
                         <table id="xTable2" lay-filter="xTable2"></table>
                     </div>-->
                    <div class="layui-tab-item">

                        <table id="xTable3" lay-filter="xTable3"></table>
                    </div>
                </div>

            </div>
        </div>
    </div>




</div>





<!-- 表格操作列 -->
<script type="text/html" id="options">

    <a class="layui-btn layui-btn-sm layui-btn-xs {:auth('mall.item_order/get_edit')}" lay-event="edit">售后详情</a>

</script>

<script type="text/html" id="category">
    {{#  if(d.Goods){ }}
    {{d.Goods.title}}
    {{#  } else { }}
    商品不存在
    {{#  } }}
</script>
<script type="text/html" id="user">
    {{#  if(d.User){ }}
    {{d.User.nick_name}}
    {{#  } else { }}
    会员不存在
    {{#  } }}
</script>
<script type="text/html" id="phone">
    {{#  if(d.User){ }}
    {{d.User.phone}}
    {{#  } else { }}
    手机号不存在
    {{#  } }}
</script>
<!-- 表单弹窗 -->


<!-- js部分 -->
{include file='public/footer' /}

<script>
    layui.use(['layer', 'table', 'admin','form','tableX'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var admin = layui.admin;
        var table = layui.table;
        // var tableX = layui.tableX;
        //线下商品
        var insTb1 =
                table.render({
                    elem: '#tableUser'
                    , autoSort: false
                    , url: "{:__url('mall.item_order/refundData')}" //数据接口
                    ,where:{
                        type:1
                    }
                    , page: true //开启分页
                    ,  cols: [[
                        {field: 'id', title: 'ID', sort: true,width:100,align: 'center'}
                        , {field: 'user', title: '用户呢称', toolbar: '#user',align: 'center'}
                        , {field: 'phone', title: '用户手机号', toolbar: '#phone',align: 'center'}
                        ,{
                            title: '金额', templet: function (d) {

                                return d.OrderList.real_price;
                            }, align: 'center',width: 150
                        }
                        ,{
                            title: '售后类型', templet: function (d) {
                                var strs = ['','<span class="layui-badge layui-bg-orange">仅退款</span>',
                                    '<span class="layui-badge layui-bg-orange">退货退款</span>',

                                ];
                                return strs[d.type];
                            }, align: 'center',width: 150
                        }
                        ,{
                            title: '状态', templet: function (d) {
                                var strs = ['<span class="layui-badge layui-bg-blue">待审核</span>',
                                    '<span class="layui-badge layui-bg-green">已通过</span>',
                                    '<span class="layui-badge layui-bg-green">已驳回</span>',
                                    '<span class="layui-badge layui-bg-green">同意退货，待填写退货单号</span>',
                                ];
                                return strs[d.status];
                            }, align: 'center',width: 150
                        }
                        , {field: 'create_time', title: '创建时间',align: 'center'}
                        , {fixed: 'right', align: 'center', title:'操作', toolbar: '#options',width: 180}
                    ]]
                });


        //监听行单击事件（双击事件为：rowDouble）
        table.on('row(tableUser)', function(obj){
            var data = obj.data;

            /* layer.alert(JSON.stringify(data), {
             title: '当前行数据：'
             });*/

            //标注选中样式
            obj.tr.addClass('layui-table-click').siblings().removeClass('layui-table-click');
        });

        //监听工具条
        table.on('tool(tableUser)', function (obj) { //注：tool是工具条事件名，dataTable是table原始容器的属性 lay-filter="对应的值"
            var data = obj.data //获得当前行数据
                    , layEvent = obj.event; //获得 lay-event 对应的值
            if (layEvent === 'edit') {

                showEditModel('查看售后订单','/mall.item_order/refund_detail?id='+ data.id );

            }
        });



        // 显示表单弹窗
        function showEditModel(title,url) {
            layer.full(admin.open({
                type: 2,
                //offset:'r',
                title: title,
                content: url,
                btn: ['确定', '关闭'],
                //area: ['500px', '100%'],
                btnAlign: 'c',   // 按钮居中
                success: function (layero, dIndex) {
                    form.render();    // 表单渲染
                },
                yes: function (index, layero) {
                    layer.close(index);

                },
                btn2: function (index, layero) {
                    layer.close(index);
                }


            }));
        }

        // 搜索
        form.on('submit(formSubSearchTbAdv)', function (data) {
            insTb1.reload({where: data.field}, 'data');
            //insTb2.reload({where: data.field}, 'data');
            insTb3.reload({where: data.field}, 'data');
        });


    })
</script>

</body>
</html>
